package com.canxin.dao;

import java.util.List;

import org.jeecgframework.minidao.annotation.Arguments;
import org.jeecgframework.minidao.annotation.MiniDao;
import org.jeecgframework.minidao.annotation.ResultType;
import org.jeecgframework.minidao.annotation.Sql;

import com.canxin.entity.ScoreEntity;

@MiniDao
public interface ScoreDao {

	@Arguments({"studentId"})
	@ResultType(ScoreEntity.class)
	public List<ScoreEntity> list(String studentId);

	@Arguments({"examId"})
	@ResultType(ScoreEntity.class)
	@Sql("SELECT * from canxin_score where examid=:examId")
	public List<ScoreEntity> getAllStudentScoresByExamId(String examId);

	@Arguments({"studentId","examId"})
	@ResultType(ScoreEntity.class)
	@Sql("select avg(rank) avgRank from canxin_score where studentid =:studentId and rank >0 and examid in (:examId)")
	public int getStudentAverageRankByStudentIdAndExamId(String studentId,String examId);

	@Arguments({"studentId","examId"})
	@ResultType(Double.class)
	@Sql("SELECT * from canxin_score where studentId=:studentId and examId=:examId and rank>0 ")
	public ScoreEntity getScoresByStudentIdAndExamId(String studentId, String examId);

	@Arguments({"examId","num"})
	@ResultType(ScoreEntity.class)
	@Sql("SELECT * from canxin_score where examid=:examId  and rank<=:num ")
	public List getStudentCountBeyondParamsByExamId(String examId, int num);

	@Arguments({"studentId","num"})
	@ResultType(ScoreEntity.class)
	@Sql("SELECT count(1) from canxin_score where studentid=:studentId and  rank<=:num ")
	public int getStudentRankCountBeyondParamsByStudentId(String studentId, int parseInt); 
}
